import request from '@/utils/request'
const api = 'partyConference/'

/**
 * 获取指定会议类型的拓展字段定义
 *
 * @export
 * @param {*} { conferenceType }
 * @return {*}
 */
export function getExtendTypes({ conferenceType }) {
  return request.get(`${api}extendTypes`, {
    params: {
      conferenceType
    }
  })
}

/**
 * 更新指定的拓展字段
 *
 * @export
 * @param {*} { id, isRemoved, type, name, alias, description, priority, fieldType, fieldAttribute }
 * @return {*}
 */
export function updateExtendType({ id, isRemoved, type, name, alias, description, priority, fieldType, fieldAttribute }) {
  return request.post(`${api}extendType`,
    {
      id, isRemoved, type, name, alias, description, priority,
      fieldType: fieldType || 2,
      fieldAttribute: fieldAttribute || 0
    })
}

/**
 * 获取会议的拓展字段值
 *
 * @export
 * @param {*} { conferences }
 * @return {*}
 */
export function getConferencesExtendFields({ conferences }) {
  return request.post(`${api}extendValues`, Array.isArray(conferences) ? conferences : [conferences])
}

/**
 * 更新会议拓展字段的值
 *
 * @export
 * @param {*} { conference, id, isRemoved, type, value }
 */
export function updateConferenceExtendField({ conference, id, isRemoved, type, value }) {
  return request.post(`${api}extendValue`, {
    conference, id, isRemoved, type,
    value: Array.isArray(value) ? value : [value]
  })
}
